import type { CodeType, PatientType, User, UserInfoType } from '@/types/user'
import { request } from '@/utils/request'

export const login = (mobile: string, password: string) => {
  return request<User>('login/password', 'post', {
    mobile,
    password
  })
}

/**
 * 验证码
 */
export const sendMobileCode = (mobile: string, type: CodeType) => {
  return request<{ code: string }>('code', 'get', {
    mobile,
    type
  })
}

/**
 * 验证码登录
 */

export const loginByMobile = (mobile: string, code: string) => {
  return request<User>('login', 'post', {
    mobile,
    code
  })
}

/**
 * 用户信息
 */

export const getUserInfo = () => {
  return request<UserInfoType>('patient/myUser')
}

/**
 * 患者列表
 */

export const getPatinentList = () => {
  return request<PatientType[]>('patient/mylist')
}
